package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.LotteryDrawRecord;
import com.jic.market.mapper.LotteryDrawRecordMapper;
import com.jic.market.request.manager.lottery.LotteryDrawRecordRequest;
import com.jic.market.response.manager.lottery.LotteryDrawRecordResponse;
import com.jic.market.service.LotteryDrawRecordService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖记录表
 * @author : 
 * @email : 
 * @since : 2020-03-03 03:06:20
 * @version : v1.0.0
 */
@Service
public class LotteryDrawRecordServiceImpl implements LotteryDrawRecordService{

    @Autowired
    private LotteryDrawRecordMapper lotteryDrawRecordMapper;

    @Override
    public long insert(LotteryDrawRecord lotteryDrawRecord) {
        long flag = lotteryDrawRecordMapper.insert(lotteryDrawRecord);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryDrawRecordMapper.delete(id);
    }

    @Override
    public long update(LotteryDrawRecord lotteryDrawRecord) {
        return lotteryDrawRecordMapper.update(lotteryDrawRecord);
    }

    @Override
    public LotteryDrawRecord queryByPrimaryKey(Long id){
        return lotteryDrawRecordMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryDrawRecord> query(LotteryDrawRecord lotteryDrawRecord){
        return lotteryDrawRecordMapper.query(lotteryDrawRecord);
    }

    @Override
    public PageResult<LotteryDrawRecordResponse> queryPage(LotteryDrawRecordRequest lotteryDrawRecordRequest, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryDrawRecordResponse> list = lotteryDrawRecordMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryDrawRecordRequest);
        long count = lotteryDrawRecordMapper.queryPageCount(lotteryDrawRecordRequest);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}